package com.bajiao.admin.controller.useRule;

import com.bajiao.admin.base.AdminBaseController;
import com.bajiao.common.api.vo.Result;
import com.bajiao.dto.useRule.UseRulePageVo;
import com.bajiao.entity.useRule.UseRule;
import com.bajiao.service.useRule.UseRuleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author wangw
 * 使用规则模块控制器
 */
@RestController
@RequestMapping("/sys/useRule")
@Slf4j
public class UseRuleController extends AdminBaseController<UseRule, UseRuleService> {

    @Resource
    private UseRuleService useRuleService;

    /**
     * 查询
     * @return
     */
    @GetMapping("/query")
    public Result<IPage<UseRule>> useRule(UseRulePageVo vo) {
        return Result.success(useRuleService.queryPage(vo));
    }

    /**
     * 更新
     * @return
     */
    @PostMapping("/edit")
    public Result edit(@RequestBody UseRulePageVo vo) {
        return Result.ok(useRuleService.edit(vo));
    }

    /**
     * 增加
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody UseRulePageVo vo) {
        return Result.ok(useRuleService.addUseRule(vo));
    }

    /**
     * 删除
     * @return
     */
    @PostMapping("/del/{id}")
    public Result del(@PathVariable String id) {
        return Result.ok(useRuleService.del(id));
    }

}
